/*
*		Image Buffer  ³éÏóÍ¼Æ¬»º³åÇø£¬²ÉÓÃcv::Mat´æ´¢
*/


#pragma once 

#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <opencv2/opencv.hpp>
#include <string>
#include "CxType.h"
#include "CxCommonBuffer.h"


using std::string;
using cv::Mat;



template<template<	class _Ty,
				class _Ax = std::allocator<_Ty> >	class __StoreType>

class  CxImageBuffer  : public CxCommonBuffer< Mat , __StoreType >
{
protected:

    typedef boost::condition_variable_any   _Cond;
    typedef boost::mutex					_Mutex;


    _Mutex			m_mu;

public:
	explicit	CxImageBuffer(size_t _bufsiz=16):
			CxCommonBuffer< Mat , __StoreType >(_bufsiz)
	{
		CX_ASSERT(_bufsiz);
	}

	virtual		~CxImageBuffer()
	{
		Clear();
	}

public:

	void		Clear()
	{
        CX_ASSERT(this->m_maxbufsiz);
		_Mutex::scoped_lock lock(m_mu);

		if(IsEmpty())return ;
        else this->m_buffer.clear();
	}

	bool		IsEmpty()const
	{
        return this->m_buffer.size()==0;
	}

	bool		IsFull()const
	{
        CX_ASSERT(this->m_maxbufsiz);
        return this->m_buffer.size()== this->m_maxbufsiz;
	}

	string		BufferType()const{return string("ImageBuffer");}
};



